package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysNoticeReceiver;
import com.ruoyi.system.mapper.SysNoticeReceiverMapper;
import com.ruoyi.system.service.ISysNoticeReceiverService;

/**
 * 通知公告接收者 服务层实现
 * 
 * @author ruoyi
 */
@Service
public class SysNoticeReceiverServiceImpl implements ISysNoticeReceiverService
{
    @Autowired
    private SysNoticeReceiverMapper noticeReceiverMapper;

    /**
     * 查询公告接收者信息
     * 
     * @param id 主键ID
     * @return 接收者信息
     */
    @Override
    public SysNoticeReceiver selectNoticeReceiverById(Long id)
    {
        return noticeReceiverMapper.selectNoticeReceiverById(id);
    }

    /**
     * 查询公告接收者列表
     * 
     * @param noticeReceiver 接收者信息
     * @return 接收者集合
     */
    @Override
    public List<SysNoticeReceiver> selectNoticeReceiverList(SysNoticeReceiver noticeReceiver)
    {
        return noticeReceiverMapper.selectNoticeReceiverList(noticeReceiver);
    }

    /**
     * 根据公告ID查询接收者列表
     * 
     * @param noticeId 公告ID
     * @return 接收者集合
     */
    @Override
    public List<SysNoticeReceiver> selectNoticeReceiverByNoticeId(Long noticeId)
    {
        return noticeReceiverMapper.selectNoticeReceiverByNoticeId(noticeId);
    }

    /**
     * 新增公告接收者
     * 
     * @param noticeReceiver 接收者信息
     * @return 结果
     */
    @Override
    public int insertNoticeReceiver(SysNoticeReceiver noticeReceiver)
    {
        noticeReceiver.setCreateTime(new Date());
        return noticeReceiverMapper.insertNoticeReceiver(noticeReceiver);
    }

    /**
     * 批量新增公告接收者
     * 
     * @param noticeReceiverList 接收者列表
     * @return 结果
     */
    @Override
    public int batchInsertNoticeReceiver(List<SysNoticeReceiver> noticeReceiverList)
    {
        for (SysNoticeReceiver receiver : noticeReceiverList) {
            receiver.setCreateTime(new Date());
        }
        return noticeReceiverMapper.batchInsertNoticeReceiver(noticeReceiverList);
    }

    /**
     * 修改公告接收者
     * 
     * @param noticeReceiver 接收者信息
     * @return 结果
     */
    @Override
    public int updateNoticeReceiver(SysNoticeReceiver noticeReceiver)
    {
        return noticeReceiverMapper.updateNoticeReceiver(noticeReceiver);
    }

    /**
     * 删除公告接收者信息
     * 
     * @param id 主键ID
     * @return 结果
     */
    @Override
    public int deleteNoticeReceiverById(Long id)
    {
        return noticeReceiverMapper.deleteNoticeReceiverById(id);
    }

    /**
     * 根据公告ID删除接收者
     * 
     * @param noticeId 公告ID
     * @return 结果
     */
    @Override
    public int deleteNoticeReceiverByNoticeId(Long noticeId)
    {
        return noticeReceiverMapper.deleteNoticeReceiverByNoticeId(noticeId);
    }

    /**
     * 批量删除公告接收者信息
     * 
     * @param ids 需要删除的主键ID
     * @return 结果
     */
    @Override
    public int deleteNoticeReceiverByIds(Long[] ids)
    {
        return noticeReceiverMapper.deleteNoticeReceiverByIds(ids);
    }
}
